/*
 * Title:        CloudScheduler Toolkit
 * Description:  a Toolkit for Modeling and Simulation of Job Scheduling and Resource Provisioning in Cloud System
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 * Author:       Fuhui Wu
 *
 * Copyright (c) 2013-2014, The National University of Defense Technology, China
 */

package org.nudt.jCloud.simulation;

public class SimEvent implements Cloneable, Comparable<SimEvent>{
	private final int eventType;
	private final double time;
	private int src;
	private int dst;
	private final int tag;
	private final Object data;
	private long serial = -1;
	
	//Internal event types
	public static final int ENULL = 0;
	public static final int SEND = 1;
	public static final int HOLD_DONE = 2;
	public static final int CREATE = 3;
	
	public SimEvent(int eventType, double time, int src, int dst, int tag, Object data){
		this.eventType = eventType;
		this.time = time;
		setSrc(src);
		setDst(dst);
		this.tag = tag;
		this.data = data;
	}

	public int compareTo(SimEvent event) {
		// TODO Auto-generated method stub
		if(event == null){
			return 1;
		}else if(time < event.time){
			return -1;
		}else if(time > event.time){
			return 1;
		}else if(serial < event.serial){
			return -1;
		}else if(this == event){
			return 0;
		}else{
			return 1;
		}
	}
	
	@Override
	public SimEvent clone(){
		return new SimEvent(eventType, time, src, dst, tag, data);
	}

	/**
	 * @return the eventType
	 */
	public int getEventType() {
		return eventType;
	}

	/**
	 * @return the time
	 */
	public double getTime() {
		return time;
	}

	/**
	 * @return the src
	 */
	public int getSrc() {
		return src;
	}

	/**
	 * @param src the src to set
	 */
	public void setSrc(int src) {
		this.src = src;
	}

	/**
	 * @return the dst
	 */
	public int getDst() {
		return dst;
	}

	/**
	 * @param dst the dst to set
	 */
	public void setDst(int dst) {
		this.dst = dst;
	}

	/**
	 * @return the serial
	 */
	public long getSerial() {
		return serial;
	}

	/**
	 * @param serial the serial to set
	 */
	public void setSerial(long serial) {
		this.serial = serial;
	}

	/**
	 * @return the tag
	 */
	public int getTag() {
		return tag;
	}

	/**
	 * @return the data
	 */
	public Object getData() {
		return data;
	}
	
}
